﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FrameWork.Entity;
using Microsoft.ApplicationBlocks.Data;
using System.Data.SqlClient;
using System.Collections;

namespace FrameWork.web.Code
{
    public class its_ReliefLogCs
    {
        public its_ReliefLogCs()
        {
            Microsoft.ApplicationBlocks.Data.SqlHelper.connectionString = ConfigurationManager.AppSettings["MsSql"].ToString();
        }
        
        /// <summary>
        /// 添加交接班信息
        /// </summary>
        /// <param name="_its_ReliefLog"></param>

        public void ReliefLog_Add(its_ReliefLog _its_ReliefLog)
        {
            SqlParameter[] sp = new SqlParameter[5]{
				new SqlParameter("@USERNO",SqlDbType.VarChar,20),
				new SqlParameter("@USERNAME",SqlDbType.NVarChar,120),
				new SqlParameter("@RELIEFNO",SqlDbType.Int),
				new SqlParameter("@RELIEFDAT",SqlDbType.DateTime),
				new SqlParameter("@CONTENT",SqlDbType.NText),
		
			};
            //
            
                sp[0].Value = _its_ReliefLog.USERNO;
           
            sp[0].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.USERNAME != "")
            {
                sp[1].Value = _its_ReliefLog.USERNAME;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.RELIEFNO != int.MinValue)
            {
                sp[2].Value = _its_ReliefLog.RELIEFNO;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.RELIEFDAT != DateTime.MinValue)
            {
                sp[3].Value = _its_ReliefLog.RELIEFDAT;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.CONTENT != "")
            {
                sp[4].Value = _its_ReliefLog.CONTENT;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ReliefLog_Add", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        /// <summary>
        /// 删除交接班信息
        /// </summary>
        /// <param name="_its_ReliefLog"></param>
        public void ReliefLog_Del(its_ReliefLog _its_ReliefLog)
        {
            SqlParameter[] sp = new SqlParameter[1]{
				new SqlParameter("@UID",SqlDbType.Int),
			
			};
            //

            sp[0].Value = _its_ReliefLog.UID;
            sp[0].Direction = ParameterDirection.Input;


            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ReliefLog_Del", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 修改交接班信息
        /// </summary>
        /// <param name="_its_ReliefLog"></param>
        public void ReliefLog_Update(its_ReliefLog _its_ReliefLog)
        {
            SqlParameter[] sp = new SqlParameter[7]{
				new SqlParameter("@UID",SqlDbType.Int),
				new SqlParameter("@USERNO",SqlDbType.VarChar,20),
				new SqlParameter("@USERNAME",SqlDbType.NVarChar,120),
				new SqlParameter("@RELIEFNO",SqlDbType.Int),
				new SqlParameter("@RELIEFDAT",SqlDbType.DateTime),
				new SqlParameter("@FILLINDAT",SqlDbType.DateTime),
				new SqlParameter("@CONTENT",SqlDbType.NText),
			
			};
            //
            //if (_its_ReliefLog.UID != int.MinValue)
            //{
                sp[0].Value = _its_ReliefLog.UID;
            //}
            //else
            //{
            //    sp[0].Value = DBNull.Value;
            //}

            sp[0].Direction = ParameterDirection.Input;


            //
            //if (_its_ReliefLog.USERNO != "")
            //{
                sp[1].Value = _its_ReliefLog.USERNO;
            //}
            //else
            //{
            //    sp[1].Value = DBNull.Value;
            //}

            sp[1].Direction = ParameterDirection.Input;


            //
            //if (_its_ReliefLog.USERNAME != "")
            //{
                sp[2].Value = _its_ReliefLog.USERNAME;
            //}
            //else
            //{
            //    sp[2].Value = DBNull.Value;
            //}

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.RELIEFNO != int.MinValue)
            {
                sp[3].Value = _its_ReliefLog.RELIEFNO;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.RELIEFDAT != DateTime.MinValue)
            {
                sp[4].Value = _its_ReliefLog.RELIEFDAT;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.FILLINDAT != DateTime.MinValue)
            {
                sp[5].Value = _its_ReliefLog.FILLINDAT;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (_its_ReliefLog.CONTENT != "")
            {
                sp[6].Value = _its_ReliefLog.CONTENT;
            }
            else
            {
                sp[6].Value = DBNull.Value;
            }

            sp[6].Direction = ParameterDirection.Input;


            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ReliefLog_Update", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 交接单查询
        /// </summary>
        /// <param name="USERNO"></param>
        /// <param name="RELIEFDATBegin"></param>
        /// <param name="RELIEFDATEnd"></param>

        public ArrayList ReliefLog_Select(its_ReliefLog _its_ReliefLog, int PageIndex, int PageSize)
        {
            SqlParameter[] sp = new SqlParameter[4]{
				new SqlParameter("@USERNO",SqlDbType.VarChar,20),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@PageSize",SqlDbType.Int),
				new SqlParameter("@PageCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = _its_ReliefLog.USERNO;
            sp[0].Direction = ParameterDirection.Input;


            //

            sp[1].Value = PageIndex;
            sp[1].Direction = ParameterDirection.Input;


            //

            sp[2].Value = PageSize;
            sp[2].Direction = ParameterDirection.Input;

            //
            sp[3].Direction = ParameterDirection.Output;

            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ReliefLog_Select", sp);
                DataTable dt = ds.Tables[0];
                ArrayList arr = new ArrayList();
                arr.Add((int)sp[3].Value);
                arr.Add(dt);
                return arr;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



    }
}
